package com.transaction.demo.accounting.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.transaction.demo.common.util.Result;
import com.transaction.demo.common.util.ResultPage;
import com.transaction.demo.accounting.vo.req.AccountingVoucherReqVo;
import com.transaction.demo.accounting.vo.req.AccountingVoucherListReqVo;
import com.transaction.demo.accounting.vo.req.AccountingVoucherAddReqVo;
import com.transaction.demo.accounting.vo.req.AccountingVoucherUpdateReqVo;
import com.transaction.demo.accounting.vo.resp.AccountingVoucherRespVo;
import com.transaction.demo.accounting.service.AccountingVoucherService;

/**
 * 描述：会计原始凭证表
 * 作者：马庆智
 * 日期：2023/04/27 17:54:01
 */
@Api(tags = "会计原始凭证表")
@RestController
@RequestMapping("/accountingVoucher")
@EnableTransactionManagement
public class AccountingVoucherController {

   @Autowired
   private AccountingVoucherService accountingVoucherService;

   /**
    * 查询会计原始凭证表
    *
    * @param record 请求参数
    * @return AccountingVoucherResp
    * @author 马庆智
    * @date: 2023/04/27 17:54:01
    */
   @ApiOperation("查询会计原始凭证表")
   @PostMapping("/queryAccountingVoucher")
   public AccountingVoucherRespVo query(@RequestBody @Valid AccountingVoucherReqVo record){
       return accountingVoucherService.queryAccountingVoucher(record);
   }

   /**
    * 查询会计原始凭证表列表
    *
    * @param record 请求参数
    * @return AccountingVoucherResp
    * @author 马庆智
    * @date: 2023/04/27 17:54:01
    */
   @ApiOperation("查询会计原始凭证表列表")
   @PostMapping("/queryAccountingVoucherList")
   public Result<ResultPage<AccountingVoucherRespVo>> queryAccountingVoucherList(@RequestBody @Valid AccountingVoucherListReqVo record){
        return Result.success(accountingVoucherService.queryAccountingVoucherList(record));
   }

   /**
    * 添加会计原始凭证表
    *
    * @param record 请求参数
    * @return Result<Integer>
    * @author 马庆智
    * @date: 2023/04/27 17:54:01
    */
   @ApiOperation("添加会计原始凭证表")
   @PostMapping("/saveAccountingVoucher")
   public Result<Integer> saveAccountingVoucher(@RequestBody @Valid AccountingVoucherAddReqVo record){
        return Result.success(accountingVoucherService.saveAccountingVoucher(record));
   }

   /**
    * 删除会计原始凭证表
    *
    * @param ids 请求参数
    * @return Result<Integer>
    * @author 马庆智
    * @date: 2023/04/27 17:54:01
    */
   @ApiOperation("删除会计原始凭证表")
   @PostMapping("/deleteAccountingVoucher")
   public Result<Integer> deleteAccountingVoucher(String ids){
        return Result.success(accountingVoucherService.deleteAccountingVoucher(ids));
   }

   /**
    * 更新会计原始凭证表
    *
    * @param record 请求参数
    * @return Result<Integer>
    * @author 马庆智
    * @date: 2023/04/27 17:54:01
    */
   @ApiOperation("更新会计原始凭证表")
   @PostMapping("/updateAccountingVoucher")
   public Result<Integer> updateAccountingVoucher(@RequestBody @Valid AccountingVoucherUpdateReqVo record){
        return Result.success(accountingVoucherService.updateAccountingVoucher(record));
   }

}